package cc.cary.warehouse.exception;


import cc.cary.warehouse.common.ErrorMessages;

import static cc.cary.warehouse.common.ErrorConstants.ERR_UNKNOWN;

/**
 * 业务异常
 *
 * @author Cary
 * @date 2023/1/16
 */
public class ServiceException extends RuntimeException {
    private int errorCode;
    private String message;

    public ServiceException(int errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
        this.message = message;
    }

    public ServiceException(String message) {
        super(message);
        this.message = message;
        this.errorCode = ERR_UNKNOWN;
    }

    public ServiceException(int errorCode) {
        super(ErrorMessages.getErrorMessage(errorCode));
        this.errorCode = errorCode;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }
}
